package com.byhealth.codeTable.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.byhealth.codeTable.dao.CodeTableDao;
import com.byhealth.codeTable.service.CodeTableService;

/**
 * 
 * 
 * */
@Service
public class CodeTableServiceImpl implements CodeTableService{
	
	@Resource
	private CodeTableDao codeTableDao;
	
	/**
	 * 获取所有sql
	 * */
	public void getALLSql(){
		codeTableDao.getALLSql();
	}
	
	/**
	 * 查询sql
	 * */
	public List<Map<String, Object>> query(String sql_no,HashMap<String, String> param){
		String sql = codeTableDao.getSql(sql_no, param);
		System.out.println(sql);
		return codeTableDao.query(sql_no, sql);
	}
	
	/**
	 * 查询数据量
	 * */
	public int queryCount(String sql_no,HashMap<String, String> param){
		String sql = codeTableDao.getSql(sql_no, param);
		return codeTableDao.queryCount(sql_no, sql);
	}
	
	/**
	 * 查询sql
	 * */
	public Map<String, Object> queryFirst(String sql_no,HashMap<String, String> param){
		String sql = codeTableDao.getSql(sql_no, param);
		return codeTableDao.queryFirst(sql_no, sql);
	}
	
	/**
	 * 根据表名,一个条件精确删除数据
	 * */
	public Boolean deleteTableByOneCondition(String tableName, String fieldName, Object fieldValue) {
		return codeTableDao.deleteTableByOneCondition( tableName,  fieldName,  fieldValue);
	}
}
